//
//  MessageRegisterViewController.m
//  WuJieLive
//
//  Created by iMac on 2017/10/19.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "MessageRegisterViewController.h"
#import "TextFieldLineView.h"
#import "SetPasswordViewController.h"

@interface MessageRegisterViewController ()<GetCodeDelegate>
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;

@end

@implementation MessageRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];

}

- (void)setNavi
{
    self.title = @"注册";
}

- (void)setUI
{
    NSString * string = [self.telephoneNumber substringFromIndex:7];
    self.numberLabel.text = [NSString stringWithFormat:@"已向尾号%@的手机发送验证码",string];
    TextFieldLineView * view = [[TextFieldLineView alloc] initWithFrame:CGRectMake(30,CGRectGetMaxY(self.numberLabel.frame) + 60, kScreenWidth - 60,45)];
    view.delegate = self;
    view.backgroundColor =[UIColor whiteColor];
    // 验证码（显示数字）
    view.secureTextEntry = NO;
    [self.view addSubview:view];
    [view becomeFirstResponder];
}

- (void)getCode:(NSString *)messageCode
{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    NSDictionary * dict = @{@"check_code":messageCode,@"phone_redis_key":self.redisKey};
    [HTTPTool POSTForm:[NSString stringWithFormat:@"%@member/register-sms-check",BaseUrl] para:dict success:^(BOOL isSuccess, id responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if (isSuccess) {
            SetPasswordViewController * vc = [[SetPasswordViewController alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
